import { _decorator, Component, Node, Sprite } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('ProgressBar')
export class ProgressBar extends Component {

    @property(Node) fillBar: Node = null;  //填充条

    private _fillSprite: Sprite = null;  //精灵组件

    protected onLoad(): void {
        this._fillSprite = this.fillBar.getComponent(Sprite);
    }
    start() {

    }

    update(deltaTime: number) {

    }
    /**
     * 设置进度条进度
     * @param progress 进度值，范围0-1
     */
    setProgress(progress: number = 0) {
        progress > 1 && (progress = 1);
        progress < 0 && (progress = 0);
        this._fillSprite.fillRange = progress;  //设置填充条填充比例
    }
}


